const path = require("path");
// const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    publicPath: process.env.NODE_ENV === 'production' ? '././' : './',
    outputDir: "dist/wmsj-pc/",
    assetsDir: "./static",
    productionSourceMap: false,
    parallel: false,
    lintOnSave: false,

    devServer: {
        // 配置自动启动浏览器
        proxy: {
            '/mpsh': {
                target: 'http://tbknew.mpcheshi.com/mpsh', //对应自己的接口
                changeOrigin: true,//n是false：请求头中host仍然是浏览器发送过来的host；如果设置成true：发送请求头中host会设置成target。
                ws: true,
                pathRewrite: {
                    '^/mpsh': ''//路径重写，这里理解成用'/api'代替target里面的地址.
                }
            },

        },
        overlay: {
            // 关闭eslint提示的错误
            warnings: true,
            errors: true,
        },
    },
    configureWebpack: {
        plugins: [
            // new UglifyJsPlugin({
            //     uglifyOptions: {
            //         compress: {
            //             drop_console: true,
            //         },
            //     },
            // }),
            new CopyWebpackPlugin({
                patterns:
                    [
                        { from: 'node_modules/@liveqing/liveplayer/dist/component/crossdomain.xml' },
                        { from: 'node_modules/@liveqing/liveplayer/dist/component/liveplayer.swf' },
                        { from: 'node_modules/@liveqing/liveplayer/dist/component/liveplayer-lib.min.js', to: 'js/' },
                    ]
            }

            )
        ],
        resolve: {
            alias: {
                "@": path.join(__dirname, "src"),
                assets: "@/assets",
                components: "@/components",
                common: "@/common",
                views: "@/views",
                utils: "@/utils",
                api: "@/api"
            }
        },
        externals: {

            // 全局常量定义出，也可以是window下的实例

            'AMap': 'AMap'  // 高德地图配置

        }
    },

    css: {
        loaderOptions: {
            sass: {
                javascriptEnabled: true,
            },
        },
    },
    runtimeCompiler: true,
};


